package com.acme.iolab.filecopy.io;

import com.acme.iolab.filecopy.FileCopyHelper;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class IOFileCopyHelper extends FileCopyHelper {

    @Override
    public void copyFile(File sourceFile, File targetFile) throws IOException {
        try (FileInputStream src = new FileInputStream(sourceFile);
             FileOutputStream trg = new FileOutputStream(targetFile)) {
            final byte[] buffer = new byte[100000];
            int n;
            while ((n = src.read(buffer)) != -1) {
                trg.write(buffer, 0, n);
            }
            System.out.println("file copied!");
        }
    }
}
